package com.business.service.weixin;


import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.business.wechat.bean.WeixinReplyBean;

import net.sf.rose.jdbc.PageBean;
import net.sf.rose.jdbc.dao.BeanDAO;
import net.sf.rose.jdbc.query.BeanSQL;
import net.sf.rose.web.util.WebUtils;

@Service
public class WeixinReplyService {

    /**
     * 获取回复信息列表
     */
    public PageBean page(HttpServletRequest request, BeanDAO dao) {
        PageBean page = WebUtils.getPageBean(request);
        BeanSQL query = dao.getQuerySQL();
        query.setEntityClass(WeixinReplyBean.class);
        query.createSql(WebUtils.getRequestData(request));
        query.setPage(page);
        dao.list();
        return page;
    }

    /**
     * 获取回复信息
     */
    public WeixinReplyBean load(BeanDAO dao, String id) {
        BeanSQL query = dao.getQuerySQL();
        query.setEntityClass(WeixinReplyBean.class);
        query.createSql(id);
        WeixinReplyBean bean = dao.load();
        return bean;
    }

    /**
     * 保存回复信息
     */
    public int save(BeanDAO dao, WeixinReplyBean bean) {
        BeanSQL query = dao.getQuerySQL();
        query.createSaveSql(bean);
        return dao.update();
    }

    /**
     * 删除回复信息
     */
    public int delete(BeanDAO dao, String id) {
        BeanSQL query = dao.getQuerySQL();
        query.createDeleteSql(WeixinReplyBean.class, id);
        return dao.update();
    }
}
